﻿<views:RibbonWindowView x:TypeArguments="viewModels:MainWindowViewModel" x:Class="Flux.Editor.MainWindow"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:views="clr-namespace:Flux.Mvvm.Views;assembly=Flux.Mvvm"
		xmlns:viewModels="clr-namespace:Flux.Editor.ViewModels"
		xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
		xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
		xmlns:panes="clr-namespace:Flux.Editor.Panes"
		xmlns:converters="clr-namespace:Flux.Editor.Converters"
		xmlns:controls="clr-namespace:Flux.Editor.Controls"
		Width="1024" Height="768"
		WindowStartupLocation="CenterScreen"
		Title="Flux Editor"
		Loaded="MainWindow_OnLoaded">

	<Window.Resources>
		<ResourceDictionary>
			<converters:ActiveDocumentConverter x:Key="ActiveDocumentConverter"/>
		</ResourceDictionary>
	</Window.Resources>

	<Grid x:Name="LayoutRoot">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition/>
		</Grid.RowDefinitions>

		<Ribbon Grid.Row="0" SelectedIndex="0" Title="Unity Enterprise">
			<Ribbon.HelpPaneContent>
				<RibbonButton SmallImageSource="Resources/Help.png"/>
			</Ribbon.HelpPaneContent>

			<Ribbon.ApplicationMenu>
				<RibbonApplicationMenu>
                    <RibbonApplicationMenuItem Header="Start" ImageSource="Resources/start-here-2.png" Command="{Binding StartCommand}"/>
					<RibbonApplicationMenuItem Header="Options" ImageSource="Resources/Config.png" Command="{Binding ConfigCommand}"/>
					<RibbonApplicationMenuItem Header="Exit" ImageSource="Resources/Exit.png" Command="{Binding ExitCommand}"/>
				</RibbonApplicationMenu>
			</Ribbon.ApplicationMenu>

			<RibbonTab Header="Home">
				<RibbonGroup Header="Project">
					<RibbonButton LargeImageSource="Resources/project-new.png" Label="New" Command="{Binding NewProjectCommand}"/>
					<RibbonButton SmallImageSource="Resources/open.png" Label="Open"/>
					<RibbonButton SmallImageSource="Resources/save.png" Label="Save"/>
				</RibbonGroup>
				<RibbonGroup Header="Tiles">
                    <Border BorderBrush="Black" BorderThickness="0,0,1,1">
                        <Border BorderBrush="#7FB0FF" BorderThickness="1,1,0,0">
					        <Canvas Background="{Binding SelectedLeftTile, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="48" Height="48"/>
                        </Border>
                    </Border>
                    <Border BorderBrush="Black" BorderThickness="0,0,1,1" Margin="4,0,0,0">
                        <Border BorderBrush="#7FB0FF" BorderThickness="1,1,0,0">
                            <Canvas Background="{Binding SelectedRightTile, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="48" Height="48"/>
                        </Border>
                    </Border>
				</RibbonGroup>
			</RibbonTab>

			<RibbonTab Header="Maps">
			</RibbonTab>

		</Ribbon>

		<xcad:DockingManager Grid.Row="1"
							 DocumentsSource="{Binding Panes, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
							 ActiveContent="{Binding ActivePane, Mode=TwoWay, Converter={StaticResource ActiveDocumentConverter}}"
							 DocumentClosing="DockingManager_OnDocumentClosing">

			<xcad:DockingManager.Theme>
				<xcad:VS2010Theme/>
			</xcad:DockingManager.Theme>

			<xcad:DockingManager.LayoutItemContainerStyleSelector>
				<panes:PanesStyleSelector>
					<panes:PanesStyleSelector.PaneStyle>
						<Style TargetType="{x:Type xcad:LayoutItem}">
							<Setter Property="Title" Value="{Binding Model.Name}"/>
							<Setter Property="CloseCommand" Value="{Binding Model.CloseCommand}"/>
						</Style>
					</panes:PanesStyleSelector.PaneStyle>
				</panes:PanesStyleSelector>
			</xcad:DockingManager.LayoutItemContainerStyleSelector>

			<xcad:DockingManager.LayoutItemTemplateSelector>
				<panes:PaneTemplateSelector>
					<panes:PaneTemplateSelector.StartPageViewTemplate>
						<DataTemplate>
							<ContentPresenter ContentTemplate="{StaticResource StartPageViewTemplate}" DataContext="{Binding}"/>
						</DataTemplate>
					</panes:PaneTemplateSelector.StartPageViewTemplate>

                    <panes:PaneTemplateSelector.MapPaneViewTemplate>
                        <DataTemplate>
                            <ContentPresenter ContentTemplate="{StaticResource MapPaneViewTemplate}" DataContext="{Binding}"/>
                        </DataTemplate>
                    </panes:PaneTemplateSelector.MapPaneViewTemplate>
                </panes:PaneTemplateSelector>
			</xcad:DockingManager.LayoutItemTemplateSelector>

			<xcad:LayoutRoot>
				<xcad:LayoutPanel Orientation="Horizontal">
					<xcad:LayoutDocumentPane/>
					<xcad:LayoutAnchorablePane DockWidth="256">
						<xcad:LayoutAnchorable Title="Project and Properties">
							<Grid>
								<Grid.RowDefinitions>
									<RowDefinition/>
                                    <RowDefinition Height="8"/>
									<RowDefinition/>
								</Grid.RowDefinitions>
								
                                <controls:ProjectExplorer Project="{Binding ActiveProject, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="0"/>

                                <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" ShowsPreview="True" Height="6" BorderBrush="DarkSlateGray" BorderThickness="1" Background="{StaticResource HorizontalGridSplitterBackground}"/>

                                <TabControl Grid.Row="2" TabStripPlacement="Bottom" x:Name="utilityTabControl">
									<TabItem Header="Properties">
										<xctk:PropertyGrid UpdateTextBoxSourceOnEnterKey="true" SelectedObject="{Binding SelectedObject, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
									</TabItem>
									<TabItem Header="Tilesets">
										<controls:TilesetPanel/>
									</TabItem>
                                    <TabItem Header="Layers">
                                        <controls:LayerManagerPanel Map="{Binding ActiveMap, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                                    </TabItem>
								</TabControl>

							</Grid>
						</xcad:LayoutAnchorable>
					</xcad:LayoutAnchorablePane>
				</xcad:LayoutPanel>
				<xcad:LayoutRoot.LeftSide>
					<xcad:LayoutAnchorSide>
						<xcad:LayoutAnchorGroup>
							<xcad:LayoutAnchorable Title="AutoHidden Content">
								<TextBox/>
							</xcad:LayoutAnchorable>
						</xcad:LayoutAnchorGroup>
					</xcad:LayoutAnchorSide>
				</xcad:LayoutRoot.LeftSide>
			</xcad:LayoutRoot>
		</xcad:DockingManager>

	</Grid>
</views:RibbonWindowView>
